﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using b7.Models;

namespace b7.Controllers
{
    [Authorize]
    public class CheckoutController : Controller
    {
        //
        // GET: /Checkout/
        b7Models db = new b7Models();
        const string PromoCode = "FREE";
        public ActionResult Index()
        {
            return View();
        }
        // GET: /Checkout/AddressAndPayment
        public ActionResult AddressAndPayment()
        {
            return View();
        }
        // POST: /Checkout/AddressAndPayment
        [HttpPost]
        public ActionResult AddressAndPayment(FormCollection values)
        {
            //var order = new Orders();
            //TryUpdateModel(order);

            //try
            //{
            //    if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false)
            //    {
            //        return View(order);
            //    }
            //    else
            //    {
            //        order.Member.UserName = User.Identity.Name;
            //        order.CreateDate = DateTime.Now;

            //        //Save Order
            //        db.Orderss.Add(order);
            //        db.SaveChanges();
            //        //Process the order
            //        var cart = ShoppingCart.GetCart(this.HttpContext);
            //        cart.CreateOrder(order);

            //        return RedirectToAction("Complete",
            //            new { id = order.OrdersId });
            //    }
            //}
            //catch
            //{
                //Invalid - redisplay with errors
                //return View(order);
           // }
            return View();
        }
        // GET: /Checkout/Complete
        public ActionResult Complete(int id)
        {
            // Validate customer owns this order
            //bool isValid = db.Orderss.Any(o => o.OrdersId == id && o.Member.UserName == User.Identity.Name);

            //if (isValid)
            //{
            //    return View(id);
            //}
            //else
            //{
            //    return View("Error");
            //}
            return View();
        }
    }
}
